#include <bits/stdc++.h>
using namespace std;
int t;
int main() {
    cin >> t;
    while(t--) {
        int x,y,d;
        cin >> x >> y >> d;
        int dx = ceil(x*1.0/d), dy = ceil(y*1.0/d);
        if(dx > dy) {
            cout << 2 * dx - 1 << endl;
        } else {
            cout << 2 * dy<<endl;
        }
    }
    return 0;
}